<!doctype html>

<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->

    <head>

        <meta charset="utf-8">

        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

        <title>FusionInvoice</title>

        <meta name="viewport" content="width=device-width,initial-scale=1">

        <link rel="stylesheet" href="<?php echo base_url(); ?>assets/default/css/bootstrap.min.css">

        <style>
            body {
                color: #000 !important;
            }
            table {
                width:100%;
            }
            #header table {
                width:100%;
                padding: 0px;
            }
            #header table td {
                vertical-align: text-top;
                padding: 5px;
            }
            #company-name{
                color:#000;
                font-size: 18px;
            }
            #invoice-to {
                /*                display: table;*/
                /*                content: "";*/
            }
            #invoice-to td {
                text-align: left
            }
            .seperator {
                height: 25px
            }
            .top-border {
                border-top: none;
            }
            .no-bottom-border {
                border:none !important;
                background-color: white !important;
            }
            .alignr {
                text-align: right;
            }
            #invoice-container {
                margin: auto;
                margin-top: 25px;
                width: 900px;
                padding: 20px;
                top:10px;
                background-color: white;
                box-shadow: 4px 4px 14px rgba(0, 0, 0, 0.8);
                overflow-y: hidden;
            }
            #menu-container {
                margin: auto;
                margin-top: 25px;
                width: 900px;
                top:10px;
                overflow-y: hidden;
            }
            .flash-message {
                font-size: 120%;
                font-weight: bold;
            }
        </style>

    </head>

    <body>

        <div id="menu-container">
            <div class="alert alert-info">
            <a href="<?php echo site_url('guest/view/generate_invoice_pdf/' . $invoice_url_key); ?>" class="btn btn-primary"><i class="icon-white icon-print"></i> Open PDF</a> 
            <?php if ($this->mdl_settings->setting('merchant_enabled') == 1) { ?><a href="<?php echo site_url('guest/payment_handler/make_payment/' . $invoice_url_key); ?>" class="btn btn-success"><i class="icon-white icon-ok"></i> Make Payment</a><?php } ?>
            </div>
            <?php if ($flash_message) { ?>
            <div class="alert flash-message">
                <?php echo $flash_message; ?>
            </div>
            <?php } ?>
        </div>

        <div id="invoice-container">

            <div id="header">
                <table>
                    <tr>
                        <td id="company-name">
                            <h2><?php echo $invoice->user_name; ?></h2>
                            <p><?php if ($invoice->user_address_1) { echo $invoice->user_address_1 . '<br>'; } ?>
                                <?php if ($invoice->user_address_2) { echo $invoice->user_address_2 . '<br>'; } ?>
                                <?php if ($invoice->user_city) { echo $invoice->user_city . ' '; } ?>
                                <?php if ($invoice->user_state) { echo $invoice->user_state . ' '; } ?>
                                <?php if ($invoice->user_zip) { echo $invoice->user_zip . '<br>'; } ?>
                                <?php if ($invoice->user_phone) { ?><abbr>P:</abbr><?php echo $invoice->user_phone; ?><br><?php } ?>
                                <?php if ($invoice->user_fax) { ?><abbr>F:</abbr><?php echo $invoice->user_fax; ?><?php } ?>
                            </p>
                        </td>
                        <td class="alignr"><h2><?php echo lang('invoice'); ?> <?php echo $invoice->invoice_number; ?></h2></td>
                    </tr>
                </table>
            </div>
            <div id="invoice-to">
                <table style="width: 100%;">
                    <tr>
                        <td>
                            <h2><?php echo $invoice->client_name; ?></h2>
                            <p><?php if ($invoice->client_address_1) { echo $invoice->client_address_1 . '<br>'; } ?>
                                <?php if ($invoice->client_address_2) { echo $invoice->client_address_2 . '<br>'; } ?>
                                <?php if ($invoice->client_city) { echo $invoice->client_city . ' '; } ?>
                                <?php if ($invoice->client_state) { echo $invoice->client_state . ' '; } ?>
                                <?php if ($invoice->client_zip) { echo $invoice->client_zip . '<br>'; } ?>
                                <?php if ($invoice->client_phone) { ?><abbr>P:</abbr><?php echo $invoice->client_phone; ?><br><?php } ?>
                            </p>
                        </td>
                        <td style="width:40%;"></td>
                        <td>
                            <table>
                                <tbody>
                                    <tr>
                                        <td><?php echo lang('invoice_date'); ?></td>
                                        <td><?php echo date_from_mysql($invoice->invoice_date_created); ?></td>
                                    </tr>
                                    <tr>
                                        <td><?php echo lang('due_date'); ?></td>
                                        <td><?php echo date_from_mysql($invoice->invoice_date_due); ?></td>
                                    </tr>
                                    <tr>
                                        <td><?php echo lang('amount_due'); ?></td>
                                        <td><?php echo format_currency($invoice->invoice_total); ?></td>
                                    </tr>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="invoice-items">
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th><?php echo lang('qty'); ?></th>
                            <th><?php echo lang('item'); ?></th>
                            <th><?php echo lang('description'); ?></th>
                            <th><?php echo lang('price'); ?></th>
                            <th><?php echo lang('total'); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($items as $item) : ?>
                            <tr>
                                <td><?php echo $item->item_quantity; ?></td>
                                <td><?php echo $item->item_name; ?></td>
                                <td><?php echo $item->item_description; ?></td>
                                <td><?php echo format_currency($item->item_price); ?></td>
                                <td><?php echo format_currency($item->item_subtotal); ?></td>
                            </tr>
                        <?php endforeach ?>
                        <tr>
                            <td colspan="3"></td>
                            <td><?php echo lang('subtotal'); ?>:</td>
                            <td><?php echo format_currency($invoice->invoice_item_subtotal); ?></td>
                        </tr>
                        <?php foreach ($invoice_tax_rates as $invoice_tax_rate) : ?>
                            <tr>    
                                <td class="no-bottom-border" colspan="3"></td>
                                <td><?php echo $invoice_tax_rate->invoice_tax_rate_name . ' ' . $invoice_tax_rate->invoice_tax_rate_percent; ?>%</td>
                                <td><?php echo format_currency($invoice_tax_rate->invoice_tax_rate_amount); ?></td>
                            </tr>
                        <?php endforeach ?>
                        <tr>
                            <td class="no-bottom-border" colspan="3"></td>
                            <td><?php echo lang('total'); ?>:</td>
                            <td><?php echo format_currency($invoice->invoice_total); ?></td>
                        </tr>
                        <tr>
                            <td class="no-bottom-border" colspan="3"></td>
                            <td><?php echo lang('paid'); ?></td>
                            <td><?php echo format_currency($invoice->invoice_paid) ?></td>
                        </tr>
                        <tr>
                            <td class="no-bottom-border" colspan="3"></td>                
                            <td><?php echo lang('balance'); ?></td>
                            <td><strong><?php echo format_currency($invoice->invoice_balance) ?></strong></td>
                        </tr>
                    </tbody>
                </table>
                <div class="seperator"></div>
                
                <?php if ($invoice->invoice_terms) { ?>
                <h4><?php echo lang('terms'); ?></h4>
                <p><?php echo $invoice->invoice_terms; ?></p>
                <?php } ?>
            </div>

        </div>

    </body>
</html>